# -*- coding: utf-8 -*-
from utils.operators.spark_submit import SparkSubmitOperator
from datetime import timedelta

from jms.dim import jms_dim__dim_sys_network_detail_dt
from jms.dwd import jms_dwd__dwd_yl_oms_oms_waybill_incre_dt
from jms.ods import jms_ods__yl_lmdm_sys_staff, jms_ods__sys_manage_region, jms_ods__yl_lmdm_sys_special_time_limit, \
    jms_ods__yl_lmdm_sys_area, jms_ods__yl_tmsnew_download_effective, jms_ods__yl_oms_interceptorpiece, \
    jms_ods__tab_end_piece, jms_ods__tab_barscan_difficult, \
    jms_ods__tab_barscan_send, jms_ods__tab_barscan_sitearrival, jms_ods__tab_barscan_deliver, \
    jms_ods__tab_barscan_sign, jms_ods__tab_barscan_collect, jms_ods__tab_barscan_sitesend, \
    jms_ods__yl_lmdm_sys_abnormal_piece
from jms.dwd.tab.dwd_tab_reback_transfer_express_base import jms_dwd__dwd_tab_reback_transfer_express_base

jms_dwd__dwd_terminal_sign_all_detail_dt = SparkSubmitOperator(
    task_id='jms_dwd__dwd_terminal_sign_all_detail_dt',
    email=['houwenlong@jtexpress.com','yl_bigdata@yl-scm.com'],
    name='jms_dwd__dwd_terminal_sign_all_detail_dt_{{ execution_date | date_add(1) | cst_ds }}',
    pool_slots=5,
    driver_memory='20G',
    driver_cores=2,
    executor_memory='30G',
    executor_cores=4,
    num_executors=100,
    conf={'spark.sql.shuffle.partitions': 600,
          'spark.executor.memoryOverhead': 2048,
          'spark.core.connection.ack.wait.timeout': 300,
          'spark.default.parallelism': 600,
          'spark.locality.wait': 60,
          },
    jars='hdfs:///scheduler/jms/spark/chk/report/terminal_sign_data/common-1.0-SNAPSHOT.jar',  # 依赖 jar 包
    java_class='com.yunlu.bigdata.jobs.report.TerminalSignAllDetailData',  # spark 主类
    application='hdfs:///scheduler/jms/spark/chk/report/terminal_sign_data/original-jobs-1.0-SNAPSHOT.jar',
    # spark jar 包
    application_args=['{{ execution_date  | date_add(1)| cst_ds }}'],  # 参数dt 跑数据当天
    #execution_timeout=timedelta(hours=1)
    #excel平均时长:16分5秒
    execution_timeout = timedelta(minutes=60),
)

# 设置依赖
jms_dwd__dwd_terminal_sign_all_detail_dt << [
    jms_dim__dim_sys_network_detail_dt,
    jms_ods__yl_lmdm_sys_staff,
    jms_ods__sys_manage_region,
    jms_ods__yl_lmdm_sys_area,
    jms_ods__yl_tmsnew_download_effective,
    jms_ods__yl_lmdm_sys_special_time_limit,
    jms_dwd__dwd_yl_oms_oms_waybill_incre_dt,
    jms_ods__yl_oms_interceptorpiece,
    jms_dwd__dwd_tab_reback_transfer_express_base,
    jms_ods__tab_end_piece,
    jms_ods__tab_barscan_difficult,
    jms_ods__tab_barscan_send,
    jms_ods__tab_barscan_sitearrival,
    jms_ods__tab_barscan_sitesend,
    jms_ods__tab_barscan_deliver,
    jms_ods__tab_barscan_sign,
    jms_ods__tab_barscan_collect,
    jms_ods__yl_lmdm_sys_abnormal_piece
]
